//
//  DKBankCardNewController.m
//  DanKU
//
//  Created by 蓝鳍互娱 on 2023/12/13.
//

#import "DKBankCardNewController.h"
#import "DKBankCardNewCell.h"
#import "DKTabBarViewController.h"
@interface DKBankCardNewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)UITableView * bankCardTableView;
@end

@implementation DKBankCardNewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
    [self dk_addSubView];
    [self makeNavBack];
    [DKPublicHttp apiUserBrhavRecordForAPI:@{} withPageName:DK_EditBankcard withAction:DK_ActionEnter complete:^{
            
    } fail:^{
            
    }];
}
- (void)dk_addSubView{
    UIImageView * dk_BankCardHeadBg = [[UIImageView alloc] init];
    dk_BankCardHeadBg.userInteractionEnabled = YES;
    dk_BankCardHeadBg.image = DK_GetImage(@"dk_MainBankCardHeadBg");
    [self.view addSubview:dk_BankCardHeadBg];
    [dk_BankCardHeadBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(DK_IsWidthScale(0)));
        make.height.equalTo(@(DK_IsWidthScale(200)));
    }];
    
    self.bankCardTableView = [[UITableView alloc] init];
    self.bankCardTableView.backgroundColor = UIColor.clearColor;
    self.bankCardTableView.delegate = self;
    self.bankCardTableView.dataSource = self;
    self.bankCardTableView.estimatedRowHeight = 0;
    self.bankCardTableView.estimatedSectionHeaderHeight = 0;
    self.bankCardTableView.estimatedSectionFooterHeight = 0;
    self.bankCardTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.bankCardTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    self.bankCardTableView.showsVerticalScrollIndicator = NO;
    self.bankCardTableView.shouldIgnoreScrollingAdjustment = YES;
    self.bankCardTableView.shouldRestoreScrollViewContentOffset = YES;
    [self.view addSubview:self.bankCardTableView];
    [self.bankCardTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@(DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
}
#pragma mark -- UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return DK_IsWidthScale(781)+DK_SafeAreaBottom;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    WeakSelf(self)
    DKBankCardNewCell *dk_BankCardNewCell = [DKBankCardNewCell bankCardNewCell:tableView];
    dk_BankCardNewCell.bankCardView = self.view;
    dk_BankCardNewCell.CheckPrivateAgrmentBlock = ^{
        DKWebViewController * dk_WebViewCtrl = [[DKWebViewController alloc] initWithUrl:DK_PrivacyAgreement withIsNavBar:YES];
        [weakSelf.navigationController pushViewController:dk_WebViewCtrl animated:YES];
    };
    dk_BankCardNewCell.RequestScuessBankCardAuthBlock = ^{
        DKTabBarViewController * dk_TabBarViewCtrl = [[DKTabBarViewController alloc] init];
        dk_TabBarViewCtrl.isAuth = YES;//默认未认证，未认证会再次识别
        ((AppDelegate*)([UIApplication sharedApplication].delegate)).window.rootViewController = dk_TabBarViewCtrl;
        [DKAlertHelper showMessage:@"You have successfully modified your bank account information！"];
    };
    return dk_BankCardNewCell;
}
@end
